// 
//  WTRecord.m
//  WorkTimer
//
//  Created by Gerhard Sletten on 06.01.06.
//  Copyright 2006 __MyCompanyName__. All rights reserved.
//

#import "WTRecord.h"


@implementation WTRecord 

+ (void)initialize {
    if (self == [WTRecord class])
    {
		NSArray *keys = [NSArray arrayWithObjects:
                @"seconds", nil];
        [self setKeys:keys triggerChangeNotificationsForDependentKey:@"timestring"];
    }
}
- (void)awakeFromInsert
{
    [super awakeFromInsert];
    [self setValue:[NSDate date]
            forKey:@"date"];
}

- (NSString *)timestring 
{
	//NSLog(@"seconds: %i",[[self valueForKey:@"seconds"] intValue]);
    return [NSString stringWithString:intToTimeString( [[self valueForKey:@"seconds"] intValue])];
}

// Copy
+ (NSArray *)copyKeys {
    static NSArray *copyKeys = nil;
    if (copyKeys == nil) {
        copyKeys = [[NSArray alloc] initWithObjects:
            @"title", @"date", @"seconds", @"notes", nil];
    }
    return copyKeys;
}
- (NSDictionary *)dictionaryRepresentation
{
    return [self dictionaryWithValuesForKeys:[[self class] copyKeys]];
}
- (NSString *)stringDescription
{
	NSString *stringDescription = @"";
    stringDescription = [stringDescription stringByAppendingFormat:
        @"%@ \t%@ \t%@ \t%@", 
			[self valueForKey:@"title"],
			[[self valueForKey:@"date"] descriptionWithCalendarFormat:@"%d. %b %Y" timeZone:nil locale:nil], 
			[self valueForKey:@"timestring"],
			[self valueForKey:@"notes"]];
    return stringDescription;
}





@end
